package previous.Test_0408;

import java.util.ArrayList;
import java.util.PriorityQueue;

/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 */
public class Solution {
    //最小k个数
    public ArrayList<Integer> GetLeastNumbers_Solution (int[] input, int k) {
        // write code here
        ArrayList<Integer> list=new ArrayList<>();
        PriorityQueue<Integer> q=new PriorityQueue<>();
        for (int i = 0; i < input.length; i++) {
            q.offer(input[i]);
        }
        while(k!=0){
            list.add(q.poll());
            k--;
        }
        return list;
    }

}
